﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using SES.CMS.DO;
using SES.CMS.BL;

namespace SES.CMS
{
    public partial class About : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["ID"] != null)
                {
                    if (Session["lang"] != null)
                    {
                        string s = Request.QueryString["ID"].ToString();
                        int id = 0;
                        try
                        {
                            id = int.Parse(s);
                        }
                        catch
                        {
                            id = int.Parse(s.Substring(0, s.IndexOf(",")));
                        }
                        cmsCategoryDO objCat = new cmsCategoryDO();
                        objCat.CategoryID = id;
                        objCat = new cmsCategoryBL().Select(objCat);
                        if (Session["lang"].ToString() == "VN")
                        {
                            Page.Title = objCat.Title + " - KMA";
                            lblInfo.Text = objCat.DetailContent;
                        }
                        else
                        {
                            Page.Title = objCat.eTitle + " - KMA";
                            lblInfo.Text = objCat.eDetailContent;
                        }
                        DataTable dt = new DataTable();
                        dt = new cmsCategoryBL().SelectByParentID(id, 5);
                        if (dt.Rows.Count > 0)
                        {
                            rpt.Visible = true;
                            //lbl.Text = "<span style=\"font-weight: bold; color:#CC0D01\">CÁC BÀI VIẾT LIÊN QUAN</span>";
                            rpt.DataSource = dt;
                            rpt.DataBind();
                        }
                        else
                        {
                            lbl.Visible = false;
                            rpt.Visible = false;
                        }
                    }
                }
            }
        }
        protected string FriendlyUrl(string strTitle)
        {
            return Ultility.Change_AV(strTitle);
        }
        public string CheckDate(string sDate)
        {
            if (sDate != "")
            {
                //kiem tra ngay thang neu nho hon ngay hien tai (chu y parse sang datetime) 
                DateTime startDate = Convert.ToDateTime(sDate);
                DateTime now = DateTime.Now;
                TimeSpan elapsed = now.Subtract(startDate);
                double daysAgo = elapsed.TotalDays;
                if (daysAgo < 30)
                {
                    return "<img src=\"/images/New_icons_07.gif\" AlternateText=\"New\" />";
                }
                else
                {
                    return " ";
                }
            }
            else
            {
                return "";
            }
        }
    }
}
